﻿// usage: 
//Object.toType(window); //"global" (all browsers)
//Object.toType([1, 2, 3]); //"array" (all browsers)
//Object.toType(/a-z/); //"regexp" (all browsers)
//Object.toType(JSON); //"json" (all browsers)
////etc..

Object.toType = (function toType(global) {
    return function (obj) {
        if (obj === global) {
            return "global";
        }
        return ({}).toString.call(obj).match(/\s([a-z|A-Z]+)/)[1].toLowerCase();
    }
})(this);


